<?php
class Category extends CI_Controller{
    
    function index()
    {
        $this->load->model('category_model','category');
        $data['list_category'] = $this->category->get_list_category();
        $this->load->view('category/index',$data);
        
    }
    
    function item()
    {
        $id = $this->input->get('id');
        if(!empty($id))
        {
            $this->load->model('category_model','category');
            $data['item'] = $this->category->get_item($id);
            $data['category'] = $this->category->get_list_category();
            $this->load->view('category/item',$data);
            
        }else{
            
            $this->load->model('category_model','category');
            $data['category'] = $this->category->get_list_category();
            $this->load->view('category/item',$data);
        }
    }
    
    function remove()
    {
        $id = $this->input->get('id');
        if(!empty($id))
        {
            $this->load->model('category_model','category');
            $this->category->remove_category($id);
        }
    }
    
    function add()
    {
        $data = $this->input->post();
        if(!empty($data['submit']))
        {
            $this->load->model('category_model','category');
            $this->category->add_category($data);
        }
    }
}
?>